﻿using System.Windows;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Debug;
using Prism.Ioc;
using Prism.Modularity;
using YF_Music.Core.Events;
using YF_Music.Core.Services;
using YF_Music.Modules.APP_My;
using YF_Music.Service;
using YF_Music.Views;

namespace YF_Music
{
  /// <summary>
  /// Interaction logic for App.xaml
  /// </summary>
  public partial class App
  {
    protected override Window CreateShell()
    {
      return Container.Resolve<MainWindow>();
    }

    protected override void RegisterTypes(IContainerRegistry containerRegistry)
    {
      containerRegistry.RegisterSingleton<IMusicPlayerService, MusicPlayerService>();
      containerRegistry.RegisterSingleton<IHttpService, HttpService>();
      containerRegistry.RegisterSingleton(typeof(PublishCoreEvent));
      var loggerFactory = LoggerFactory.Create(builder =>
      {
        builder.AddDebug();
        builder.SetMinimumLevel(LogLevel.Debug);
      });
      containerRegistry.RegisterInstance(loggerFactory);
      containerRegistry.Register(typeof(ILogger<>), typeof(Logger<>));
    }

    protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog)
    {
      moduleCatalog.AddModule<APP_My_Module>();
    }
  }
}
